<!--
 * @Description: 定制其他
 * 
 * @Author: XiongYaoYuan<xiongyaoyuan>
 * @Date: 2023-07-19 22:09:38
 * @FilePath: /yuxiuproweb/src/views/split/order/mods/cell/other.vue
-->
<template>
  <div>
    <h2>定制其他</h2>
    <el-table :data="list" size="mini" border>
      <el-table-column
        label="变更单状态"
        align="center"
        prop="name1"
        width="120"
      >
        <template slot-scope="{ $index }">
          <template v-if="info.type === '1'">
            {{ ($index + 1) % 2 === 1 ? "修改前" : "修改后" }}
          </template>
          <template v-else>
            {{
              info.type === "0"
                ? "新增"
                : info.type === "1"
                ? "修改"
                : info.type === "2"
                ? "删除"
                : ""
            }}
          </template>
        </template>
      </el-table-column>
      <el-table-column label="房间" align="center" prop="name1" width="120">
        <template slot-scope="{ row }">
          {{ row.room.name }}
        </template>
      </el-table-column>
      <el-table-column label="品名" align="center" prop="name" width="120">
        <template slot-scope="{ row, $index }">
          <span :style="handleCompare('name', $index) ? 'color: red' : ''">{{
            row.name
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="宽" align="center" prop="wright" width="70">
        <template slot-scope="{ row, $index }">
          <span :style="handleCompare('wright', $index) ? 'color: red' : ''">{{
            row.wright
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="高" align="center" prop="height" width="70">
        <template slot-scope="{ row, $index }">
          <span :style="handleCompare('height', $index) ? 'color: red' : ''">{{
            row.height
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="单价" align="center" prop="unitPrice" width="70">
        <template slot-scope="{ row, $index }">
          <span
            :style="handleCompare('unitPrice', $index) ? 'color: red' : ''"
            >{{ row.unitPrice }}</span
          >
        </template>
      </el-table-column>
      <el-table-column
        label="加工方式"
        align="center"
        prop="processingMethod"
        width="130"
      >
        <template slot-scope="{ row, $index }">
          <span
            :style="
              handleCompare('processingMethod', $index) ? 'color: red' : ''
            "
            >{{ row.processingMethod }}</span
          >
        </template>
      </el-table-column>
      <el-table-column label="数量" align="center" prop="number" width="70">
        <template slot-scope="{ row, $index }">
          <span :style="handleCompare('number', $index) ? 'color: red' : ''">
            {{ row.number }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="小计" align="center" prop="subtotal" width="100">
        <template slot-scope="{ row, $index }">
          <span :style="handleCompare('subtotal', $index) ? 'color: red' : ''">
            {{ row.subtotal
            }}{{ row.updataPrice ? `(${row.updataPrice})` : "" }}
          </span>
        </template>
      </el-table-column>
      <el-table-column
        label="加工备注"
        align="center"
        prop="processingRemarks"
        width="150"
      >
        <template slot-scope="{ row, $index }">
          <span
            :style="
              handleCompare('processingRemarks', $index) ? 'color: red' : ''
            "
          >
            {{ row.processingRemarks }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="余料" align="center" prop="oddments" width="70">
        <template slot-scope="{ row, $index }">
          <span :style="handleCompare('oddments', $index) ? 'color: red' : ''">
            {{
              row.oddments === "0"
                ? "无"
                : row.oddments === "1"
                ? "寄回"
                : row.oddments === "2"
                ? "加工"
                : ""
            }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="配件" align="center" prop="mounting" width="70">
        <template slot-scope="{ row, $index }">
          <span :style="handleCompare('mounting', $index) ? 'color: red' : ''">
            {{ row.mounting }}
          </span>
        </template>
      </el-table-column>
      <el-table-column
        label="明细"
        align="center"
        prop="detail"
        min-width="200"
      >
        <template slot-scope="{ row, $index }">
          <span :style="handleCompare('detail', $index) ? 'color: red' : ''">
            {{ row.detail }}
          </span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  dicts: ["order_curtain_section"],
  props: {
    show: Boolean,
    list: {
      type: Array,
      default: () => [],
    },
    info: {
      type: Object,
    },
  },
  data() {
    return {};
  },
  methods: {
    handleCompare(key, index) {
      if (this.info.type === "1") {
        if ((index + 1) % 2 === 1) {
          const item1 = this.list?.[index];
          const item2 = this.list?.[index + 1];
          return item1[key] != item2[key];
        } else {
          const item1 = this.list?.[index];
          const item2 = this.list?.[index - 1];
          return item1[key] != item2[key];
        }
      }
      return false;
    },
  },
};
</script>
